# @Time    :2025/4/7 0:03
class Deque(object):
    """双端队列"""

    def __init__(self):
        self._list = []

    def add_front(self, item):
        """ 从队头加入一个item元素"""
        self._list.insert(0, item)

    def add_rear(self, item):
        """ 从队尾加入一个item元素"""
        self._list.append(item)


    # def remove_front(self):
    #     """ 从队头删除一个item元素"""
    #
    #
    # def remove_rear(self):
    #     """ 从队尾删除一个item元素"""
    def pop_front(self):
        """ 从队头删除一个item元素"""
        return self._list.pop(0)
    def pop_rear(self):
        """ 从队尾删除一个item元素"""
        return self._list.pop()
    def is_empty(self):
        """ 判断双端队列是否为空"""
        return len(self._list) == []
    def size(self):
        """返回队列的大小"""
        return len(self._list)
if __name__ == '__main__':
    d = Deque()
    d.add_front(1)
    d.add_front(2)
    d.add_front(3)
    d.add_rear(4)
    d.add_rear(5)
    d.add_rear(6)
    print(d._list)
    print(d.pop_front())
    print(d.pop_front())
    print(d.pop_front())
    print(d.pop_rear())